'use strict';
// const fs = require('fs');
// const path = require('path');
// const { domain } = require('../app/constants/url');

module.exports = appInfo => {

  return {
    // use for cookie sign key, should change to your own and keep security
    keys: appInfo.name + '_1326584236598_2649',

    // add your config here
    middleware: [],

    cluster: {
      listen: {
        port: 1217,
        hostname: '127.0.0.1',
      },
    },

    static: {
      prefix: '/',
    },

    /** 测试数据库 **/
    mongoose: {
      url: 'mongodb://libo:libo@119.23.9.0:27017/sp-businessCard',
      options: {
        useMongoClient: true,
      },
    },

    security: {
      csrf: {
        ignore: [ '/api/v1/upload' ],
        enable: false,
        headerName: 'x-csrf-token',
      },
    },

    /** 文件上传 **/
    multipart: {
      whitelist: [
        // image
        '.jpg',
        '.jpeg',
        '.png',
        '.gif',
        '.bmp',
        '.wbmp',
        '.webp',
        '.tif',
      ],
      fileSize: '10mb',
    },

    // /** 线上数据库 **/
    // mongoose: {
    //   url: 'mongodb://userName:pwd@ip:port/databaseName',
    //   options: {
    //     useMongoClient: true,
    //   },
    // },

    /** 日志级别 **/
    logger: {
      level: 'DEBUG',
    },

    /** wechat **/
    // wechat: {
    //   appid: 'wx7568cf426b76fed5',
    //   appsecret: '3814348ace421d628223b68f01e10eb3',
    //   token: 'gznuode0512',
    //   encodingAESKey: 'kIjGjd93FDidSDe8zEIiPpiY8fUBmJPkOu7Uf66Q9mF',
    //   pay: {
    //     appId: 'wx7568cf426b76fed5',
    //     partnerKey: '2017guangzhounuode0512gznuodellg',
    //     mchId: '1493400472',
    //     notifyUrl: domain + '/api/v1/wechat/notify',
    //     pfx: fs.readFileSync(path.resolve(__dirname, '../app/constants/cert', 'apiclient_cert.p12')),
    //   },
    // },

    /** session **/
    session: {
      key: 'sp-BusinessCard',
      maxAge: 30 * 60 * 1000, // 30 mins
      httpOnly: false,
      encrypt: true,
      rolling: true,
    },
  };
};
